<template>
	<view>
		<view style="position: relative;">
			<view class="btn">
				<u-icon name="arrow-left" size="48" @click="gobtn" color="#ffffff"></u-icon>
			</view>
			<image :src="banner1" mode="aspectFill" style="width: 750rpx;height: 400rpx;;display: block;"></image>
			<view class="head-title u-m-b-30" style="position: absolute;top: 150rpx;left: 30rpx;display: block;background: #ffffffd4;padding: 5px 10px;">
				<view>
					<text class="u-font-40" style="color: #e21001;font-weight: bold;">党政企支持</text>
				</view>
				<view class="u-p-t-4">
					<text class="u-font-30">双碳目标 两网融合</text>
				</view>
			</view>
		</view>
		<view class="grid-box u-skeleton-fillet" style="margin-top: -50rpx;position: relative;z-index: 999;">
			<view class="head-title">
				<view>
					<text>合作意向联系商务</text>
				</view>
				<text class="u-p-l-10">400-009-3039 </text>
			</view>
		</view>
		<view class="grid-box u-skeleton-fillet">
			<view class="head-title u-m-b-30">
				<view>
					<text>党政企参与再生环保的碳减排</text>
				</view>
			</view>
			<view class="paiming-list">
				<view class="item" v-for="(item,index) in carbonRanking.ranking" :key="index">
					<view>
						<!-- 金牌 -->
						<image v-if="index == 0" class="ico" src="" mode=""></image>
						<!-- 银牌 -->
						<image v-else-if="index == 1" class="ico" src="" mode=""></image>
						<!-- 铜牌 -->
						<image v-else-if="index == 2" class="ico" src="" mode=""></image>
						<view v-else class="num-tag"><text>{{index}}</text></view>
					</view>
					<text class="u-flex-1">{{item.name}}</text>
					<text class="num">{{item.carbon.toFixed(2)}}</text>
					<text class="u-font-20">CO₂</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				banner1: this.baseURL + '/banner/banner1.jpg',
				carbonRanking:{
					carbon: 0,
					ranking: []
				},
			}
		},
		onLoad() {
			this.getCarbonRanking()
		},
		methods: {
			getCarbonRanking(){
				this.$u.get('/User/Order/CarbonRanking').then((res)=>{
					console.log('减碳量排行榜',res)
					this.carbonRanking.carbon = res.carbon
					let arr = []
					res.ranking.sort((a,b)=>b.carbon - a.carbon).forEach((item,index)=>{
						// if(index < 3){
							arr.push(item)
						// }
					})
					console.log('arr',arr)
					this.carbonRanking.ranking = arr.filter((item)=>item.carbon != 0)
				})
			},
			gobtn(){
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.btn{
		position: absolute;
		top: 90rpx;
		left: 4%;
		z-index: 999;
	}
	// 宫格展示
	.grid-box {
		background-color: #fff;
		margin: 0 30rpx;
		padding: 30rpx;
		border-radius: 24rpx;
		margin-top: 30rpx;
	
		&.mt {
			margin-top: 30rpx;
			padding-top: 0;
		}
	
		.head-title {
			font-size: 32rpx;
			display: flex;
			justify-content: space-between;
	
			.more {
				color: $u-tips-color;
			}
		}
	
		.u-flex {
			flex-direction: row-reverse;
			width: 100%;
	
			.iconfont {
				font-size: 48rpx;
				margin: 0 28rpx 0 0;
				width: 60rpx;
				text-align: center;
			}
	
			.text {
				flex: 1;
				height: 80rpx;
				margin-right: 20rpx;
	
				.t1 {
					font-size: 32rpx;
					margin-bottom: 8rpx;
	
					.u-line-1 {
						width: 200rpx;
						display: block;
					}
				}
	
				.t2 {
					font-size: 24rpx;
					color: $u-tips-color;
					min-height: 16px;
	
					.u-line-1 {
						width: 200rpx;
						display: block;
					}
				}
			}
		}
	
		.u-btn {
			font-size: 30rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border-radius: 10rpx;
		}
	}
	
	.paiming-list{
		.item{
			display: flex;
			align-items: center;
			border-bottom: 1px dashed #f1f1f1;
			margin: 20rpx 0;
			.ico{
				width: 48rpx;
				height: 48rpx;
				margin-right: 10rpx;
			}
			.num{
				font-weight: bold;
				color: $u-color-orange;
			}
			.num-tag{
				color: $u-color-orange;
				width: 48rpx;
				height: 48rpx;
				margin-right: 10rpx;
				text-align: center;
				font-weight: bold;
			}
		}
	}
</style>
